メインコンテンツへスキップ

All Posts

News bits

Next.js 13.4

Next.js 13.4 がリリース。

出展:Next.js 13.4

#Stable App Router

App Router が安定版になり、公式ドキュメントもデフォルトは App Router になりました。Using App Router から切り替えられます。

https://nextjs.org/docs

App Router に抵抗感を持っていたり、RSC も含めて PHP の再来と呼んで嘲笑している方々もいますが、普通に便利なので使っていきましょう。個人的には App Router(RSC)に触れて理解を進めていけば、必然的に良いコードが書けるようになると思うので、その点でもぜひ使ってください。

https://nextjs.org/docs/app/building-your-application/configuring/draft-mode

#Server Actions (alpha)

フォームの状態について React は最近意見を持っているらしく、例えば(元々どちらかといえば制御コンポーネントを推奨していた気がしますが)現在は非制御コンポーネントを推奨していたり、ミューテーションに対するファーストパーティソリューションの開発に取り組んでいるそうです。

Server Actions は、中間層を作ることなく直接サーバーの関数を呼び出して、サーバーのデータ更新を可能になる実験的な機能です。次のような記述をします。

tsx
import db from "./db";
import { redirect } from "next/navigation";

async function create(formData: FormData) {
  "use server";
  const post = await db.post.insert({
    title: formData.get("title"),
    content: formData.get("content"),
  });
  redirect(`/blog/${post.slug}`);
}

export default function Page() {
  return (
    <form action={create}>
      <input type="text" name="title" />
      <textarea name="content" />
      <button type="submit">Submit</button>
    </form>
  );
}

著者について

Hi there. I'm hrdtbs, a frontend expert and technical consultant. I started my career in the creative industry over 13 years ago, learning on the job as a 3DCG modeler and game engineer in the indie scene.

In 2015 I began working as a freelance web designer and engineer. I handled everything from design and development to operation and advertising, delivering comprehensive solutions for various clients.

In 2016 I joined Wemotion as CTO, where I built the engineering team from the ground up and led the development of core web and mobile applications for three years.

In 2019 I joined matsuri technologies as a Frontend Expert, and in 2020 I also began serving as a technical manager supporting streamers and content creators.

I'm so grateful to be working in this field, doing something that brings me so much joy. Thanks for stopping by.